/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vclip.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.util.PortalUtil;

import com.vportal.portlet.vclip.model.ClipType;
import com.vportal.portlet.vclip.model.ClipTypeModel;
import com.vportal.portlet.vclip.model.ClipTypeSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the ClipType service. Represents a row in the &quot;ClipType&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vclip.model.ClipTypeModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ClipTypeImpl}.
 * </p>
 *
 * @author HOAN
 * @see ClipTypeImpl
 * @see com.vportal.portlet.vclip.model.ClipType
 * @see com.vportal.portlet.vclip.model.ClipTypeModel
 * @generated
 */
@JSON(strict = true)
public class ClipTypeModelImpl extends BaseModelImpl<ClipType>
	implements ClipTypeModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a clip type model instance should use the {@link com.vportal.portlet.vclip.model.ClipType} interface instead.
	 */
	public static final String TABLE_NAME = "ClipType";
	public static final Object[][] TABLE_COLUMNS = {
			{ "id_", Types.VARCHAR },
			{ "groupId", Types.BIGINT },
			{ "companyId", Types.BIGINT },
			{ "userId", Types.BIGINT },
			{ "createdDate", Types.TIMESTAMP },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "title", Types.VARCHAR },
			{ "name", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "active_", Types.BOOLEAN },
			{ "language", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table ClipType (id_ VARCHAR(75) not null primary key,groupId LONG,companyId LONG,userId LONG,createdDate DATE null,modifiedDate DATE null,title VARCHAR(2000) null,name VARCHAR(2000) null,description VARCHAR(2000) null,active_ BOOLEAN,language VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table ClipType";
	public static final String ORDER_BY_JPQL = " ORDER BY clipType.createdDate DESC";
	public static final String ORDER_BY_SQL = " ORDER BY ClipType.createdDate DESC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vclip.model.ClipType"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vclip.model.ClipType"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vclip.model.ClipType"),
			true);
	public static long ACTIVE_COLUMN_BITMASK = 1L;
	public static long LANGUAGE_COLUMN_BITMASK = 2L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static ClipType toModel(ClipTypeSoap soapModel) {
		ClipType model = new ClipTypeImpl();

		model.setId(soapModel.getId());
		model.setGroupId(soapModel.getGroupId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setUserId(soapModel.getUserId());
		model.setCreatedDate(soapModel.getCreatedDate());
		model.setModifiedDate(soapModel.getModifiedDate());
		model.setTitle(soapModel.getTitle());
		model.setName(soapModel.getName());
		model.setDescription(soapModel.getDescription());
		model.setActive(soapModel.getActive());
		model.setLanguage(soapModel.getLanguage());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<ClipType> toModels(ClipTypeSoap[] soapModels) {
		List<ClipType> models = new ArrayList<ClipType>(soapModels.length);

		for (ClipTypeSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vclip.model.ClipType"));

	public ClipTypeModelImpl() {
	}

	public String getPrimaryKey() {
		return _id;
	}

	public void setPrimaryKey(String primaryKey) {
		setId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return _id;
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey((String)primaryKeyObj);
	}

	public Class<?> getModelClass() {
		return ClipType.class;
	}

	public String getModelClassName() {
		return ClipType.class.getName();
	}

	@JSON
	public String getId() {
		if (_id == null) {
			return StringPool.BLANK;
		}
		else {
			return _id;
		}
	}

	public void setId(String id) {
		_id = id;
	}

	@JSON
	public long getGroupId() {
		return _groupId;
	}

	public void setGroupId(long groupId) {
		_groupId = groupId;
	}

	@JSON
	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	@JSON
	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	@JSON
	public Date getCreatedDate() {
		return _createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		_columnBitmask = -1L;

		_createdDate = createdDate;
	}

	@JSON
	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	@JSON
	public String getTitle() {
		if (_title == null) {
			return StringPool.BLANK;
		}
		else {
			return _title;
		}
	}

	public void setTitle(String title) {
		_title = title;
	}

	@JSON
	public String getName() {
		if (_name == null) {
			return StringPool.BLANK;
		}
		else {
			return _name;
		}
	}

	public void setName(String name) {
		_name = name;
	}

	@JSON
	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	@JSON
	public boolean getActive() {
		return _active;
	}

	public boolean isActive() {
		return _active;
	}

	public void setActive(boolean active) {
		_columnBitmask |= ACTIVE_COLUMN_BITMASK;

		if (!_setOriginalActive) {
			_setOriginalActive = true;

			_originalActive = _active;
		}

		_active = active;
	}

	public boolean getOriginalActive() {
		return _originalActive;
	}

	@JSON
	public String getLanguage() {
		if (_language == null) {
			return StringPool.BLANK;
		}
		else {
			return _language;
		}
	}

	public void setLanguage(String language) {
		_columnBitmask |= LANGUAGE_COLUMN_BITMASK;

		if (_originalLanguage == null) {
			_originalLanguage = _language;
		}

		_language = language;
	}

	public String getOriginalLanguage() {
		return GetterUtil.getString(_originalLanguage);
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public ClipType toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (ClipType)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		ClipTypeImpl clipTypeImpl = new ClipTypeImpl();

		clipTypeImpl.setId(getId());
		clipTypeImpl.setGroupId(getGroupId());
		clipTypeImpl.setCompanyId(getCompanyId());
		clipTypeImpl.setUserId(getUserId());
		clipTypeImpl.setCreatedDate(getCreatedDate());
		clipTypeImpl.setModifiedDate(getModifiedDate());
		clipTypeImpl.setTitle(getTitle());
		clipTypeImpl.setName(getName());
		clipTypeImpl.setDescription(getDescription());
		clipTypeImpl.setActive(getActive());
		clipTypeImpl.setLanguage(getLanguage());

		clipTypeImpl.resetOriginalValues();

		return clipTypeImpl;
	}

	public int compareTo(ClipType clipType) {
		int value = 0;

		value = DateUtil.compareTo(getCreatedDate(), clipType.getCreatedDate());

		value = value * -1;

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		ClipType clipType = null;

		try {
			clipType = (ClipType)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		String primaryKey = clipType.getPrimaryKey();

		if (getPrimaryKey().equals(primaryKey)) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return getPrimaryKey().hashCode();
	}

	@Override
	public void resetOriginalValues() {
		ClipTypeModelImpl clipTypeModelImpl = this;

		clipTypeModelImpl._originalActive = clipTypeModelImpl._active;

		clipTypeModelImpl._setOriginalActive = false;

		clipTypeModelImpl._originalLanguage = clipTypeModelImpl._language;

		clipTypeModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<ClipType> toCacheModel() {
		ClipTypeCacheModel clipTypeCacheModel = new ClipTypeCacheModel();

		clipTypeCacheModel.id = getId();

		String id = clipTypeCacheModel.id;

		if ((id != null) && (id.length() == 0)) {
			clipTypeCacheModel.id = null;
		}

		clipTypeCacheModel.groupId = getGroupId();

		clipTypeCacheModel.companyId = getCompanyId();

		clipTypeCacheModel.userId = getUserId();

		Date createdDate = getCreatedDate();

		if (createdDate != null) {
			clipTypeCacheModel.createdDate = createdDate.getTime();
		}
		else {
			clipTypeCacheModel.createdDate = Long.MIN_VALUE;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			clipTypeCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			clipTypeCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		clipTypeCacheModel.title = getTitle();

		String title = clipTypeCacheModel.title;

		if ((title != null) && (title.length() == 0)) {
			clipTypeCacheModel.title = null;
		}

		clipTypeCacheModel.name = getName();

		String name = clipTypeCacheModel.name;

		if ((name != null) && (name.length() == 0)) {
			clipTypeCacheModel.name = null;
		}

		clipTypeCacheModel.description = getDescription();

		String description = clipTypeCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			clipTypeCacheModel.description = null;
		}

		clipTypeCacheModel.active = getActive();

		clipTypeCacheModel.language = getLanguage();

		String language = clipTypeCacheModel.language;

		if ((language != null) && (language.length() == 0)) {
			clipTypeCacheModel.language = null;
		}

		return clipTypeCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(23);

		sb.append("{id=");
		sb.append(getId());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append(", createdDate=");
		sb.append(getCreatedDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", title=");
		sb.append(getTitle());
		sb.append(", name=");
		sb.append(getName());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", active=");
		sb.append(getActive());
		sb.append(", language=");
		sb.append(getLanguage());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(37);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vclip.model.ClipType");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>id</column-name><column-value><![CDATA[");
		sb.append(getId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdDate</column-name><column-value><![CDATA[");
		sb.append(getCreatedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>title</column-name><column-value><![CDATA[");
		sb.append(getTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>name</column-name><column-value><![CDATA[");
		sb.append(getName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>active</column-name><column-value><![CDATA[");
		sb.append(getActive());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>language</column-name><column-value><![CDATA[");
		sb.append(getLanguage());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = ClipType.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			ClipType.class
		};
	private String _id;
	private long _groupId;
	private long _companyId;
	private long _userId;
	private String _userUuid;
	private Date _createdDate;
	private Date _modifiedDate;
	private String _title;
	private String _name;
	private String _description;
	private boolean _active;
	private boolean _originalActive;
	private boolean _setOriginalActive;
	private String _language;
	private String _originalLanguage;
	private long _columnBitmask;
	private ClipType _escapedModelProxy;
}